package com.njust.RateMyTray_backend.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njust.RateMyTray_backend.entity.Favorite;
import com.njust.RateMyTray_backend.vo.FavoriteVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface FavoriteMapper extends BaseMapper<Favorite> {
    @Select("SELECT f.id as favoriteId, 'dish' as targetType, f.target_id as targetId, " +
            "d.dish_name as targetName, d.image_url as targetImageUrl " +
            "FROM t_favorite f JOIN t_dish d ON f.target_id = d.id " +
            "WHERE f.owner_id = #{userId} AND f.target_type = 'dish'")
    List<FavoriteVO> findFavoriteDishesByUserId(@Param("userId") Long userId);

    @Select("SELECT f.id as favoriteId, 'window' as targetType, f.target_id as targetId, " +
            "w.window_name as targetName, w.cover_image_url as targetImageUrl " +
            "FROM t_favorite f JOIN t_window w ON f.target_id = w.id " +
            "WHERE f.owner_id = #{userId} AND f.target_type = 'window'")
    List<FavoriteVO> findFavoriteWindowsByUserId(@Param("userId") Long userId);
} 